import request from "../index";

// 查询商品
export const ProductList = (params: IProductList): RpI<IProductListRes> =>
  request.get("/product/list", { params: params });

// 根据品牌名称分页获取品牌列表
export const BrandList = (params: BrandList): RpI<any> =>
  request.get("/brand/list", { params: params });

// 查询所有一级分类及子分类
export const ProductCategoryListwithChildren = (): RpI<
  ICategoryChildrenRse[]
> => request.get(`/productCategory/list/withChildren`);

// 批量修改删除状态
export const ProductUpdateDeleteStatus = (
  params: IProductUpdateDeleteStatus
): RpI<any> => request.post(`/product/update/deleteStatus`, {}, { params });

// 批量设为新品
export const ProductUpdateNewStatus = (
  params: IProductUpdateNewStatus
): RpI<any> => request.post(`/product/update/newStatus`, {}, { params });

// 批量上下架
export const ProductUpdatePublishStatus = (
  params: IProductUpdatePublishStatus
): RpI<any> => request.post(`/product/update/publishStatus`, {}, { params });

// 批量推荐商品
export const ProductUpdateRecommendStatus = (
  params: IProductUpdateRecommendStatus
): RpI<any> => request.post(`/product/update/recommendStatus`, {}, { params });

// 批量修改审核状态
export const ProductUpdateVerifyStatus = (
  params: IProductUpdateVerifyStatus
): RpI<any> => request.post(`/product/update/verifyStatus`, {}, { params });

// 分页查询商品分类
export const ProductCategoryList = (params: ICategoryList): RpI<any> =>
  request.get(`/productCategory/list/${params.parentId}`, {
    params: { pageNum: params.pageNum, pageSize: params.pageSize },
  });

// 分页获取所有商品属性分类
export const ProductAttributeCategoryList = (params: IProduct): RpI<any> =>
  request.get(`/productAttribute/category/list`, { params });

// 创建商品
export const ProductCreate = (productParam: IProduct): RpI<any> =>
  request.post(`/product/create`, productParam);
